package base;

import java.util.Arrays;
import java.util.Collections;

public class RotateArrayNTimes {

	public static void main(String[] args) {
		
		int a[] = { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 };
		move(a,3);
		display(a);
		//func(a,70);
	}

	public static void display(int a[]) {
		for (int a1 : a) {
			System.out.print(a1 + ",");
		}
	}

	public static void move(int[] a,int count){
		for(int i=0;i<count;i++){
			int temp = a[0];
			for(int j=0;j<a.length-1;j++){
				a[j]= a[j+1];
			}
			a[a.length-1]=temp;
		}
	}
	
	public static void func(int[] a,int search){
		int index =0;
		for(int i=0;i<a.length;i++){
			if(i!=a.length-1){
				if(a[i]>a[i+1]){
					index = i+1;
				}
			}
		}
		System.out.println("index is "+index);
		int binaryIndex =0;
		if(search>=a[0] && search <= a[index-1]){
			binaryIndex = Arrays.binarySearch(Arrays.copyOf(a,index), search);	
		}else{
			int[] newdest = {};
			System.arraycopy(a, index, newdest , a.length, a.length-1-index);
			binaryIndex = Arrays.binarySearch(newdest, search);	
		}
		System.out.println("BinaryIndex is "+binaryIndex);
	}

}
